<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="medium" :inline="true" label-width="60px">
      <el-form-item label="查询栏" prop="problemStatus">
        <el-select v-model="queryParams.problemStatus" placeholder="请选择是否有问题" style="width:100%" clearable
          @keyup.enter.native="handleQuery">
          <el-option v-for="(dict, index) in ascArr" :key="index" :label="dict" :value="index + ''">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-date-picker v-model="TimeList" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
          @keyup.enter.native="handleQuery" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="medium" @click="handleSelect">
          搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      TimeList: [],
      // 查询参数
      queryParams: {
        problemStatus: undefined
      },
    }
  },
  computed: {
    ascArr () {
      return {
        '0': '无问题',
        '1': '有问题',
      }
    }
  },
  methods: {
    handleSelect () {
      let params = {
        ...this.queryParams,
        'params[beginTime]': this.TimeList && this.TimeList.length ? this.TimeList[0] : undefined,
        'params[endTime]': this.TimeList && this.TimeList.length ? this.TimeList[1] : undefined
      }
      this.$emit('handleQuery', params)
    },
    resetQuery () {
      for (const key in this.queryParams) {
        this.queryParams[key] = null
      }
      this.TimeList = []
      this.$emit('handleQuery', this.queryParams)
    }
  }
}
</script>

<style>

</style>